package ru.pachkun.home.pages;

import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;


public abstract class Page  {

	protected WebDriver webDriver;
	protected WebDriverWait wait;
	protected PageManager pages;
	protected final int Time_OUT_PAGE;

	public Page(PageManager pages) {
		this.pages = pages;
		this.Time_OUT_PAGE= PageManager.Time_OUT_PAGE;
		this.webDriver = pages.getDriver();
		wait = new WebDriverWait(webDriver, Time_OUT_PAGE);
	}

	public WebDriver getWebDriver() {
		return webDriver;
	}

	public String getTitle() {
		return webDriver.getTitle();
	}

	public Page ensurePageLoaded() {
		return this;
	}

	public boolean waitPageLoaded() {
		try {
			ensurePageLoaded();
			return true;
		} catch (TimeoutException to) {
			return false;
		}
	}
}
